package com.tiancheng.trade.payment.controller.admin;

import com.tiancheng.trade.commom.core.data.Result;
import com.tiancheng.trade.payment.service.PaymentRefundService;
import com.tiancheng.trade.payment.vo.admin.PaymentRefundFlowQueryVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 退款
 */
@RestController
@RequestMapping("/admin/refund")
@Validated
@Slf4j
public class PaymentRefundAdminController {

    @Autowired
    private PaymentRefundService paymentRefundService;

    /**
     * 根据id获取退款详情
     *
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Result get(@PathVariable Long id) {
        return Result.success(paymentRefundService.getInfo(id));
    }

    /**
     * 分页查询退款
     *
     * @param paymentRefundVO
     * @return
     */
    @GetMapping("/findPageList")
    public Result findPageList(PaymentRefundFlowQueryVo paymentRefundVO) {
        return Result.success(paymentRefundService.findList(paymentRefundVO));
    }

    /**
     * 导出渠道支付订单
     */
    @PostMapping("/exportList")
    public Result exportList(@RequestBody PaymentRefundFlowQueryVo paymentRefundVO, HttpServletResponse response) throws IOException {
        return paymentRefundService.exportList(paymentRefundVO, response);
    }
}
